package com.qf.usefull.dict.entity;

/**
 * 实体类
 */
public class Word implements Comparable<Word>{

    private String english;

    private String chinese;


    private Word next;  // 记录当前单词关联的下一个单词

    public Word() {
    }

    public Word(String english, String chinese) {
        this.english = english;
        this.chinese = chinese;
    }

    public Word getNext() {
        return next;
    }

    public void setNext(Word next) {
        this.next = next;
    }

    public String getEnglish() {
        return english;
    }

    public void setEnglish(String english) {
        this.english = english;
    }

    public String getChinese() {
        return chinese;
    }

    public void setChinese(String chinese) {
        this.chinese = chinese;
    }

    @Override
    public String toString() {
        return "Word{" +
                "english='" + english + '\'' +
                ", chinese='" + chinese + '\'' +
                '}';
    }

    /**
     * 当前的单词对象跟传入的单词对象进行大小的比较
     * @param other the object to be compared.
     * @return 0 代表两个单词相等；-1，代表当前单词小；1 代表当前单词大
     */
    @Override
    public int compareTo(Word other) {

        // 如何比较两个单次的大小呢
        // 只考虑 english的大小
        String otherEnglish = other.getEnglish();
        return english.compareTo(otherEnglish);

    }
}
